1 using UnityEngine;
2 using
System.Collections;
3
4 public
class ActionRotateTo : TemporalAction {
5     
private float startRotation;
6     
private float endRotation;
7
8
9     
public ActionRotateTo(float rotation, float duration)
10     {
11         
this.endRotation = rotation;
12         SetDuration(duration);
13     }
14
15     
public ActionRotateTo(float rotation, float duration, Interpolation interpolation)
16     {
17         
this.endRotation = rotation;
18         SetDuration(duration);
19         SetInterpolation(interpolation);
20     }
21
22     
protected override void begin()
23     {
24         startRotation = actor.gameObject.transform.localRotation.z;
25     }
26
27     
protected override void end()
28     {
29     }
30
31     
protected override void UpdateAction(float percent)
32     {
33         actor.gameObject.transform.localRotation = Quaternion.Euler(actor.gameObject.transform.localRotation.x, actor.gameObject.transform.localRotation.y, startRotation + (endRotation - startRotation) * percent);
34     }
35 }



Trò chơi đua xe động vật trong UNITY Engine 114.641 lượt xem

Gõ tìm kiếm nhanh...